# include <iostream>
# include <sstream> 
# include <string>
# include <thread>
# include <vector>
# include <regex>
# include "include/Formater.h"
# include "include/Log.h"
# include "include/Logger.h"
# include "include/LogStreamInterface.h"
# include <chrono>


int main() {
	ZDSJ::Log* log = new ZDSJ::Log(ZDSJ::Level::debug, "[%level%] - [%time%] - [%line\\%%] - [%thread%] - [%file%] - [%func%] - [%message%]");
	
	log->addStream(ZDSJ::Logger::getStreamPtr());
	log->addStream(ZDSJ::Logger::getInstance()->getStreamPtr("./log.txt"));
	log->setTimeFormate("%Y-%m-%d %H:%M:%S");

	long long now = std::chrono::duration_cast<std::chrono::milliseconds>(std::chrono::steady_clock::now().time_since_epoch()).count();
	long long last = now;
	long long begin = now;
	long long sleep = now;
	int fps = 17;
	long long end = 10 * 1000;
	while (true) {
		log->debug("this is a message: {}", "hello world");
		now = std::chrono::duration_cast<std::chrono::milliseconds>(std::chrono::steady_clock::now().time_since_epoch()).count();
		sleep = now - last;
		if (now - last < fps) {
			std::this_thread::sleep_for(std::chrono::milliseconds(fps - sleep));
		}
		last = std::chrono::duration_cast<std::chrono::milliseconds>(std::chrono::steady_clock::now().time_since_epoch()).count();
		if (now - begin > end) {
			break;
		}
	}
	delete log;
	return 0;
}